Ext.define('Emp.ux.toolbar.GridToolbar', {
	extend: 'Ext.toolbar.Toolbar',
	alias: 'widget.gridtoolbar',
	
	requires: [
		'Ext.toolbar.TextItem', 
		'Ext.ux.grid.Printer'
	],
	
	/**
	 * @cfg {Boolean} prependButtons <tt>true</tt> to insert any configured
	 *      <tt>items</tt> <i>before</i> the paging buttons. Defaults to
	 *      <tt>false</tt>.
	 */
	prependButtons: false,

	createText: '新&nbsp;&nbsp;建',// 'Create'
	createDisable: false,
	createVisible: true,

	modifyText: '修&nbsp;&nbsp;改',// 'Modify'
	modifyDisable: false,
	modifyVisible: true,

	readText: '查&nbsp;&nbsp;看',// 'Read'
	readDisable: false,
	readVisible: true,

	removeText: '删&nbsp;&nbsp;除',// 'Remove'
	removeDisable: false,
	removeVisible: true,

	printText: '打&nbsp;&nbsp;印',// 'Print'
	printDisable: false,
	printVisible: true,

	refreshText: '刷&nbsp;&nbsp;新',// 'Refresh'
	refreshDisable: false,
	refreshVisible: true,

	/**
	 * Gets the standard operation items in the toolbar
	 * 
	 * @private
	 */
	getDefaultItems: function() {
		var me = this, items = [];
		if (me.createVisible) {
			if (items.length > 0) {
				items.push('-');
			}
			items.push({
				itemId: 'create',
				disabled: me.createDisable,
				text: me.createText,
				iconCls: 'create'
			});
		}
		if (me.modifyVisible) {
			if (items.length > 0) {
				items.push('-');
			}
			items.push({
				itemId: 'modify',
				disabled: me.modifyDisable,
				text: me.modifyText,
				iconCls: 'modify'
			});
		}
		if (me.readVisible) {
			if (items.length > 0) {
				items.push('-');
			}
			items.push({
				itemId: 'read',
				disabled: me.readDisable,
				text: me.readText,
				iconCls: 'read'
			});
		}
		if (me.removeVisible) {
			if (items.length > 0) {
				items.push('-');
			}
			items.push({
				itemId: 'remove',
				disabled: me.removeDisable,
				text: me.removeText,
				iconCls: 'remove'
			});
		}
		if (me.printVisible) {
			if (items.length > 0) {
				items.push('-');
			}
			items.push({
				itemId: 'print',
				disabled: me.printDisable,
				text: me.printText,
				iconCls: 'print'
			});
		}
//		if (me.refreshVisible) {
//			if (items.length > 0) {
//				items.push('-');
//			}
//			items.push({
//				itemId: 'refresh',
//				disabled: me.refreshDisable,
//				text: me.refreshText,
//				iconCls: Ext.baseCSSPrefix + 'tbar-loading'
//			});
//		}
		return items;
	},

	initComponent: function() {
		var me = this,
			defaultItems = me.getDefaultItems(),
			userItems = me.items || me.buttons || [];
		if (me.prependButtons) {
			me.items = userItems.concat(defaultItems);
		} else {
			me.items = defaultItems.concat(userItems);
		}
		delete me.buttons;
		me.callParent();
	}
});
